package com.controller;

import com.model.IdDB;

import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;

public class IdDBProvider extends ContentProvider {
	static final Uri IDDB_URI = Uri.parse("content://IdDB/ID");
	private SQLiteDatabase mDB;

	@Override
	public int delete(Uri arg0, String arg1, String[] arg2) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String getType(Uri uri) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public Uri insert(Uri uri, ContentValues values) {
		// TODO Auto-generated method stub
		long row = mDB.insert("USER", null, values);
		if (row >= 0) {
			Uri notiuri = ContentUris.withAppendedId(IDDB_URI, row);
			getContext().getContentResolver().notifyChange(notiuri, null);
			return notiuri;
		}
		return null;
	}

	@Override
	public boolean onCreate() {
		// TODO Auto-generated method stub
		IdDB dbHelper = new IdDB(getContext());
		mDB = dbHelper.getWritableDatabase();
		return true;
	}
	@Override
	public Cursor query(Uri uri, String[] projection, String selection,
			String[] selectionArgs, String sortOrder) {
		// TODO Auto-generated method stub
		String sql;
		sql= "SELECT ID FROM USER";
		Cursor cursor = mDB.rawQuery(sql, null);
		return cursor;
	}

	@Override
	public int update(Uri uri, ContentValues values, String selection,
			String[] selectionArgs) {
		// TODO Auto-generated method stub
		return 0;
	}

}
